package com.pagepub.core.tag.validator;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.pagepub.core.tag.validate.CreateJavascriptUtil;


public class JsValidate extends TagSupport
{
	private Log log = LogFactory.getLog(JsValidate.class);

	private String validationXmlFormName;

	private String htmlFormName;
	private static CreateJavascriptUtil mju=new CreateJavascriptUtil();
	public int doStartTag() throws JspException
	{
		try
		{
			if (validationXmlFormName == null || htmlFormName == null)
			{
				this.pageContext.getOut().print("");
				return 1;
			}
			
			this.pageContext.getOut().print(mju.createOnSubmitMethod(validationXmlFormName,htmlFormName));
		}
		catch (IOException e)
		{
			log.error("JsValidate.doStartTag()==>JsValidate标签出错!" , e);
			throw new JspException("JsValidate.doStartTag()==>JsValidate标签出错!" ,e);
		}
		return 1;
	}

	public String getHtmlFormName()
	{
		return htmlFormName;
	}

	public void setHtmlFormName(String htmlFormName)
	{
		this.htmlFormName = htmlFormName;
	}

	public String getValidationXmlFormName()
	{
		return validationXmlFormName;
	}

	public void setValidationXmlFormName(String validationXmlFormName)
	{
		this.validationXmlFormName = validationXmlFormName;
	}

}
